﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using RSEngine.Core;

namespace RSEngine.Math
{
    /// <summary>
    ///	Simple struct to allows returning a complex intersection result.
    /// </summary>
    public struct Intersection
    {

        #region Variables

        /// <summary>
        ///	Did the intersection test result in a hit?
        /// </summary>
        public bool Hit;

        /// <summary>
        ///	If Hit was true, this will hold a query specific distance value.
        ///	i.e. for a Ray-Box test, the distance will be the distance from the start point
        ///	of the ray to the point of intersection.
        /// </summary>
        public float Distance;

        /// <summary>
        /// The object that has been intersected.
        /// </summary>
        public RSBase Instance;

        /// <summary>
        /// The indice of a sub element of the instance.
        /// </summary>
        public int Indice;

        /// <summary>
        /// U surface paramater of the intersection point.
        /// </summary>
        public float U;

        /// <summary>
        /// V surface paramater of the intersection point.
        /// </summary>
        public float V;

        #endregion

        #region Constructor

        /// <summary>
        ///	Constructor.
        /// </summary>
        public Intersection(bool hit, float distance)
        {
            Hit = hit;
            Distance = distance;
            Instance = null;
            Indice = -1;
            U = 0;
            V = 0;
        }

        /// <summary>
        ///	Constructor.
        /// </summary>
        public Intersection(RSBase instance, float distance)
        {
            Hit = (instance != null);
            Instance = instance;
            Distance = distance;
            Indice = -1;
            U = 0;
            V = 0;
        }

        /// <summary>
        ///	Constructor.
        /// </summary>
        public Intersection(RSBase instance, int indice, float distance, float u, float v)
        {
            Hit = (instance != null);
            Instance = instance;
            Distance = distance;
            Indice = indice;
            U = u;
            V = v;
        }

        #endregion

    }
}
